package com.javalong.affairs.module.main.adapter;

import android.content.Context;
import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;
import android.widget.TextView;

import com.javalong.affairs.R;
import com.javalong.affairs.base.constant.StatusCode;
import com.javalong.affairs.base.model.SimpleMessage;
import com.javalong.affairs.base.utils.TimeUtils;
import com.javalong.affairs.module.main.ui.NewMsgView;
import com.javalong.affairs.module.renwujinzhang.model.NoticeMsg;
import com.javalong.affairs.module.renwujinzhang.model.Task;

import java.util.List;

public class NewMsgAdapter extends BaseAdapter {
    private LayoutInflater inflater;
    private List<NoticeMsg> msgList;
    private Context mContext;

    public NewMsgAdapter(Context context, List<NoticeMsg> msgList) {
        mContext = context;
        inflater = LayoutInflater.from(context);
        this.msgList = msgList;
    }

    @Override
    public int getCount() {
        return msgList.size();
    }

    @Override
    public Object getItem(int position) {
        if (position == 0) {
            return null;
        }
        return msgList.get(position - 1);
    }

    @Override
    public long getItemId(int position) {
        return position + 1;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        NoticeMsg msgInfo = msgList.get(position);
        if (convertView == null) {
            convertView = new NewMsgView(mContext);
        }
        ((NewMsgView) convertView).initWithData(msgInfo);
        return convertView;
    }
}
